home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / libkb100.zip / LIBKB-1.00 / MAKEFILE.LNX < prev    next >
Text File  |  1996-07-23  |  8KB  |  310 lines

  1. #
  2. # Makefile for Linux and GNU make
  3. #
  4. # libkb -- a free, advanced and portable low-level keyboard library
  5. # Copyright (C) 1995, 1996 Markus Franz Xaver Johannes Oberhumer
  6. # For conditions of distribution and use, see copyright notice in kb.h 
  7. #
  8.  
  9.  
  10. # This is a ready-to-run Makefile.
  11. # do a 'make' to build the library and the test programs.
  12.  
  13. # do a 'make install' as root.
  14. # you might want to change these, but probably not.
  15. INSTALL_INCLUDEDIR := /usr/local/include
  16. INSTALL_LIBDIR := /usr/local/lib
  17.  
  18.  
  19. # /***********************************************************************
  20. # // Configuration
  21. # // Tools needed: find, install, nm, perl, sed, tr, zip
  22. # ************************************************************************/
  23.  
  24. lib_name:=kb
  25. major_shared:=1
  26. minor_shared:=0
  27.  
  28. O := .o#            # object extension
  29. A := .a#            # library extension
  30. E := .out#            # executable extension
  31.  
  32.  
  33. #
  34. # change the LIB_TARGET to suite your needs
  35.  
  36. ##LIB_TARGET := aout.static
  37. ##LIB_TARGET := aout.shared
  38. ##LIB_TARGET := elf.shared
  39.  
  40. ifeq ($(strip $(LIB_TARGET)),)
  41. LIB_TARGET := aout.static
  42. endif
  43.  
  44.  
  45. FIND    := find
  46. TOUCH   := touch
  47. ##REN     := mmv -rp
  48. REN     := mv -i
  49. INSTALL := install -m 444 -o root -g root
  50.  
  51. PWD        := $(shell pwd)
  52. DIRNAME    := $(shell echo $(PWD) | sed -e 's|.*[/\\]||')
  53. DISTNAME   := $(DIRNAME)
  54. VERSION    := $(shell echo $(DIRNAME) | sed -e 's/[^0-9]//g')
  55.  
  56. UNAME_M    := $(shell uname -m)
  57.  
  58.  
  59. # /***********************************************************************
  60. # // Directories
  61. # ************************************************************************/
  62.  
  63. SRCDIR = include:src:samples:util
  64.  
  65. vpath %.c     $(SRCDIR)
  66. vpath %.cc    $(SRCDIR)
  67. vpath %.cpp   $(SRCDIR)
  68. vpath %.h     $(SRCDIR)
  69. vpath %.hh    $(SRCDIR)
  70. vpath %.pl    $(SRCDIR)
  71.  
  72.  
  73.  
  74. # /***********************************************************************
  75. # // Compiler and linker flags
  76. # ************************************************************************/
  77.  
  78. CC            := gcc
  79. ## CFLAGS        += -v            # be verbose
  80. CFLAGS        += -DKB_DEBUG=1        # log some debug infos
  81. CFLAGS        += -Iinclude
  82. CFLAGS        += -Wall -W -pedantic    # all warnings on
  83. CFLAGS        += -O2             # optimize 
  84. ifeq ($(UNAME_M),i486)
  85. CFLAGS        += -m486             # optimize for 486
  86. endif
  87.  
  88. ### even more warnings for all library source files
  89. ifeq (1,2)
  90. CFLAGS_LIBKB  += -Wstrict-prototypes
  91. CFLAGS_LIBKB  += -Wmissing-prototypes -Wmissing-declarations
  92. CFLAGS_LIBKB  += -Wpointer-arith -Wwrite-strings -Wshadow -Wcast-align
  93. CFLAGS_LIBKB  += -Wnested-externs
  94. endif
  95.  
  96. ### debugging
  97. ifeq (1,2)
  98. CFLAGS        += -g             # include debug information
  99. else
  100. CFLAGS        += -fomit-frame-pointer     # optimize (no debugging possible)
  101. LDFLAGS       += -s            # strip executable
  102. endif
  103.  
  104. ### bounds checking
  105. ifeq (1,2)
  106. CFLAGS        += -fbounds-checking
  107. LDFLAGS       += -fbounds-checking
  108. endif
  109.  
  110. ### curses
  111. ifeq (1,1)
  112. CFLAGS_CURSES += -I/usr/include/ncurses
  113. LDLIBS_CURSES += -lncurses        # use ncurses 1.8.5 or higher
  114. else
  115. LDLIBS_CURSES += -lcurses        # use curses
  116. endif
  117.  
  118.  
  119. # /***********************************************************************
  120. # // includes and default target
  121. # ************************************************************************/
  122.  
  123. .PHONY: default all test_pgm clean realclean
  124.  
  125. default: all
  126.  
  127. STATIC_LIB = lib${lib_name}$A
  128.  
  129. ifneq ($(strip $(wildcard Makefile.inc)),)
  130. include Makefile.inc
  131. else
  132. include makefile.inc
  133. endif
  134.  
  135. SRCS += kblinux.c
  136.  
  137.  
  138. .PHONY: lib_install shared_lib_install static_lib_install
  139.  
  140. ifeq ($(strip $(LIB_TARGET)),aout.shared)
  141.   include config/linux/aout_so.mk
  142.   LIBKB = $(SHARED_LIB)
  143.   lib_install : shared_lib_install
  144.   clean:: shared_lib_clean
  145. endif
  146.  
  147. ifeq ($(strip $(LIB_TARGET)),elf.shared)
  148.   include config/linux/elf_so.mk
  149.   LIBKB = $(SHARED_LIB)
  150.   lib_install : shared_lib_install
  151.   clean:: shared_lib_clean
  152. endif
  153.  
  154. ifeq ($(strip $(LIB_TARGET)),aout.static)
  155.   LIBKB = $(STATIC_LIB)
  156.   lib_install : static_lib_install
  157. endif
  158.  
  159.  
  160. # /***********************************************************************
  161. # // rules
  162. # ************************************************************************/
  163.  
  164. CFLAGS        := $(strip $(CFLAGS))
  165. CFLAGS_LIBKB  := $(strip $(CFLAGS_LIBKB))
  166. LDFLAGS       := $(strip $(LDFLAGS))
  167. LDLIBS        := $(strip $(LDLIBS))
  168.  
  169.  
  170. # rules for compiling the library
  171. $(OBJS) : %$O : %.c
  172.     $(COMPILE.c) $(CFLAGS_LIBKB) $< $(OUTPUT_OPTION)
  173.  
  174. $(SHARED_OBJS) : %.so : %.c
  175.     $(COMPILE.c) $(SHARED_CFLAGS) $(CFLAGS_LIBKB) $< $(OUTPUT_OPTION)
  176.  
  177.  
  178. # other rules
  179. kbtst$O : %$O : %.c
  180.     $(COMPILE.c) $(CFLAGS_CURSES) $< $(OUTPUT_OPTION)
  181.  
  182. _kbname.hh: mkkbname.pl kb.h
  183.     perl -w $^ > $@
  184.  
  185. mktables$E: mktables$O
  186.     $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
  187.  
  188. 8: 8$O 
  189.     $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
  190.  
  191.  
  192. # /***********************************************************************
  193. # // main targets
  194. # ************************************************************************/
  195.  
  196. all: uppercase  8  $(LIBKB)  test_pgm
  197.  
  198.  
  199. clean::
  200.     $(RM) $(strip $(OBJS))
  201.     $(RM) *.o *.out 8 *.tmp
  202.     $(RM) libkb*.a libkb*.sa libkb*.so.*
  203.     $(RM) libkb*.tar.gz libkb*.zip
  204.  
  205. realclean: clean
  206.  
  207.  
  208. test_pgm: $(LIBKB) kbtstlnx$E simple$E sigalrm$E keycodes$E tube$E
  209.  
  210. kbtstlnx$E: kbtst$O $(LIBKB)
  211.     $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(LDLIBS_CURSES) -o $@
  212.  
  213. simple$E: simple$O $(LIBKB)
  214.     $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
  215.  
  216. sigalrm$E: sigalrm$O $(LIBKB)
  217.     $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
  218.  
  219. keycodes$E: keycodes$O $(LIBKB)
  220.     $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
  221.  
  222. tube$E: tube$O $(LIBKB)
  223.     $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lvgagl -lvga -lm -o $@
  224. ##    chmod a+rs,go-w $@
  225.  
  226.  
  227. # /***********************************************************************
  228. # // library targets
  229. # ************************************************************************/
  230.  
  231. $(STATIC_LIB): $(OBJS)
  232.     -$(RM) $@
  233.     $(AR) rcs $@ $^
  234.  
  235.  
  236. # /***********************************************************************
  237. # // installation
  238. # ************************************************************************/
  239.  
  240. .PHONY: hdr_install static_lib_install install
  241.  
  242. hdr_install : kb.h kbmlock.h
  243.     $(INSTALL) $^  $(INSTALL_INCLUDEDIR)/
  244.  
  245. static_lib_install : $(STATIC_LIB)
  246.     $(INSTALL) $^  $(INSTALL_LIBDIR)/
  247.  
  248. install :: all hdr_install lib_install
  249.     @echo 'libkb' library installed.
  250.  
  251.  
  252. # /***********************************************************************
  253. # // uppercase
  254. # // if you unzip the MSDOS distribution (libkbXXX.zip),
  255. # // make should automatically rename all files to uppercase as needed
  256. # ************************************************************************/
  257.  
  258. .PHONY: uppercase 
  259.  
  260. uppercase: $(UPPER_MAKE) $(UPPER_FILE)
  261.  
  262. $(UPPER_MAKE) $(UPPER_FILE):
  263.     -$(REN) `echo $@ | tr A-Z a-z` $@
  264.  
  265.  
  266. # /***********************************************************************
  267. # // distribution
  268. # ************************************************************************/
  269.  
  270. .PHONY: chmod chown_root tar zip rar distclean dist pack
  271.  
  272. chmod:
  273.     chmod -R go-w *
  274.  
  275. chown_root:
  276.     chown -R root:root *
  277.  
  278. tar: mkdist.pl uppercase 
  279.     $(FIND) -type f -print | perl $< $(DIRNAME) | sort | (cd .. && tar -cvf- -T-) | (cd .. && gzip -9 > $(DIRNAME)/$(DISTNAME).tar.gz)
  280.  
  281. zip: mkdist.pl uppercase 
  282.     -$(RM) $(DISTNAME).zip
  283.     $(FIND) -type f -print | perl $< $(DIRNAME) | sort | (cd .. && zip -9 -o -@ $(DIRNAME)/$(DISTNAME).zip)
  284.     $(TOUCH) -c $(DISTNAME).zip
  285.  
  286. # get the RAR archiver from ftp://ftp.elf.stuba.sk/pub/pc/pack
  287. rar: mkdist.pl uppercase 
  288.     -$(RM) $(DISTNAME).rar
  289.     $(FIND) -type f -print | perl $< $(DIRNAME) > /tmp/libkb.tmp
  290.     (cd .. && rar a -s -ds -m5 -tl $(DIRNAME)/$(DISTNAME).rar @/tmp/libkb.tmp)
  291.     $(TOUCH) -c $(DISTNAME).rar
  292.  
  293.  
  294.  
  295. distclean: 
  296.  
  297. dist: grep distclean chmod all distexe touch tar
  298.  
  299. pack: chmod zip
  300.  
  301.  
  302. # /***********************************************************************
  303. # // Autoconf (preliminary)
  304. # ************************************************************************/
  305.  
  306. .PHONY: autoscan
  307.  
  308. autoscan: 
  309.     autoscan
  310.